package com.zyc.app.woa.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Author: yingchang.zhang
 * Date  : 2014/12/15
 */
public class DBHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "woa.db";
    public static final int DATABASE_VERSION = 1;

    public DBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);

    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("CREATE TABLE IF NOT EXISTS " + AccountTable.NAME + " (" +
                AccountTable.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                AccountTable.COLUMN_NAME + " VARCHAR, " +
                AccountTable.COLUMN_OPEN_ID + " VARCHAR, " +
                AccountTable.COLUMN_WX_ID + " VARCHAR, " +
                AccountTable.COLUMN_DESC + " TEXT, " +
                AccountTable.COLUMN_AVATAR + " VARCHAR, " +
                AccountTable.COLUMN_HREF + " VARCHAR, " +
                AccountTable.COLUMN_UPDATE_TIME + " TIMESTAMP," +
                AccountTable.COLUMN_SUBSCRIBE_ARTICLES_NUM + " INTEGER" +
                ")");

        db.execSQL("CREATE TABLE IF NOT EXISTS " + ArticlesTable.NAME + " (" +
                ArticlesTable.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                ArticlesTable.COLUMN_TITLE + " VARCHAR, " +
                ArticlesTable.COLUMN_WX_ID + " VARCHAR, " +
                ArticlesTable.COLUMN_IMG_LINK + " VARCHAR," +
                ArticlesTable.COLUMN_MSG_URL + " VARCHAR," +
                ArticlesTable.COLUMN_CACHED_FILE + " VARCHAR, " +
                ArticlesTable.COLUMN_CACHE_TIME + " TIMESTAMP, " +
                ArticlesTable.COLUMN_READ_TIME + " TIMESTAMP, " +
                ArticlesTable.COLUMN_READ + " INTEGER, " +
                ArticlesTable.COLUMN_FAVORITE + " INTEGER" +
                ")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
